{{define "content"}}
{{template "page_title" .}}
<div class="row">
    <div class="col-12">
        <form id="timing" class="card" method="post">
            <div class="card-body">
                {{template "cmd_form" .}}
                <div class="row">
                    <div class="col-md-12">
                        <div class="mb-2">
                            <label class="form-label">运行时间</label>
                            <input name="time" type="text" class="flatpickr form-control" placeholder="请输入运行时间配置"
                                value="{{.Info.Time}}">
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="mb-2">
                            <label class="form-label">超时时间</label>
                            <input name="timeout" type="text" class="form-control" placeholder="请输入超时时间"
                                value="{{.Info.Timeout}}">
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="mb-2">
                            <label class="form-label">是否开启监控</label>
                            <label class="form-check form-switch">
                                <input name="is_monitor" class="form-check-input" type="checkbox"
                                    {{if eq .Info.IsMonitor 1}}checked{{end}}>
                            </label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="card-footer">
                <input name="id" type="hidden" value="{{.Info.ID}}">
                <button type="submit" class="btn btn-primary">提交</button>
                <a id="back" href="{{.BackUrl}}" class="btn btn-danger ml-2">返回</a>
            </div>
        </form>
    </div>
</div>
{{end}}
{{define "script"}}
<script type="text/javascript">
    $(document).ready(function () {
        $('.flatpickr').flatpickr({
            'enableTime': true
        });
        $('#group_id').selectize({});
        $('#agent_id').selectize({});
        $("#timing").on("submit", function (event) {
            $('#timing').ajaxSubmit({
                url: "/timing/update",
                dataType: "json",
                timeout: 60000,
                success: function (data) {
                    if (data.code == 200) {
                        window.location.href = $("#back").attr("href");
                    } else {
                        alert(data.message);
                    }
                }
            })
            return false;
        });
    });
</script>
{{end}}